<?php
header("content-type:text/html;charset=utf-8");
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class forumAction extends publicAction
{
    public function _empty()
    {
        header("HTTP/1.0 404 Not Found");
        $this->display('public:404');
    }
    public function forum(){
        $parent_forum_count=D('forum')->where("type='parent' AND state='active'")->count();
        $this->parent_forum=D('forum')->where("type='parent' AND state='active'")->select();
        for($i=0;$i<$parent_forum_count;$i++){
            $child_forum[$i]=D('forum')->where("type='child' AND state='active' AND parent_forum_id='{$this->parent_forum[$i]['id']}'")->select();
        }
        $this->assign("child_forum",$child_forum);
        $this->display();
    }
    
    public function forumDetail(){
        if($_GET['id']){
            $where=array('id'=>$_GET['id'],'state'=>'active');
            $whereMap=array('forum_id'=>$_GET['id']);
        }
        $this->forum=D('forum')->where($where)->find();//论坛信息
        $posts=M('posts');
        import('ORG.Util.Page');// 导入分页类
        $count=$posts->where($whereMap)->count();// 查询满足要求的总记录数 
        $page=new Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数 
        $show=$page->show();// 分页显示输出 
        $list=$posts->where($whereMap)->limit($page->firstRow.','.$page->listRows)->order('dateline desc')->select();//帖子信息  
        $this->assign('page',$show);//  赋值分页输出
        $this->assign('list',$list);
        $this->display();
    }
}
?>
